<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理后台</title>
<link href="Css/css.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
<!--
function fnOnBack() {
	var url = '<?php echo $this->_url('Index'); ?>';
	document.location.href = url;
}

function fnOnSubmit(form) {
	form.Save.disabled = true;
//	var pdoc = spaw1_obj.getPageHtml(spaw1_page);
//	for(var key in pdoc)
//          document.write(key+"   =   "+pdoc[key]+"<br>"); 
//	return false;
	if (form.title.value == '' ||
		form.s1.value == '0')
	{
		alert('<?php echo h(_T('ui_p_form_validation')); ?>');
		form.Save.disabled = false;
		return false;
	}

	return true;
}

// -->
</script>
<style type="text/css">
<!--
body {
	background-color: #ddeef2;
}
-->
</style>

</head>

<body onload="setredirect('<?php echo $article['city_id']; ?>');">
<div id="main_title"><a href="#">后台管理中心</a>—<?=$title?></div>
<div id="main_content">
  <form action="<?php echo $this->_url('save',array('catid' => $catid,'access' => $_REQUEST['access'])); ?>" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return fnOnSubmit(this);">
	<table width="100%" border="0" cellspacing="2" cellpadding="2">
		<tr>
		  <td width="12%" class="title">*<?=$name?></td>
		  <td><input type="text" name="title" id="title" class="wp80" value="<?php echo $article['title']; ?>"/></td>
		</tr>
		<?php
		if($displayext){
		?>
		<tr>
		  <td valign="top" class="title">工作经验</td>
		  <td><input type="text" name="ext1" id="ext1" value="<?php echo $article['ext1']; ?>"/></td>
		</tr>
		<tr>
		  <td valign="top" class="title">最低学历</td>
		  <td><input type="text" name="ext2" id="ext2" value="<?php echo $article['ext2']; ?>"/></td>
		</tr>
		<tr>
		  <td valign="top" class="title">管理经验</td>
		  <td><input type="text" name="ext3" id="ext3" value="<?php echo $article['ext3']; ?>"/></td>
		</tr>
		<tr>
		  <td valign="top" class="title">工作性质</td>
		  <td><input type="text" name="ext4" id="ext4" value="<?php echo $article['ext4']; ?>"/></td>
		</tr>
		<tr>
		  <td valign="top" class="title">招聘人数</td>
		  <td><input type="text" name="ext5" id="ext5" value="<?php echo $article['ext5']; ?>"/></td>
		</tr>
		<tr>
		  <td valign="top" class="title">汇报对象</td>
		  <td><input type="text" name="ext6" id="ext6" value="<?php echo $article['ext6']; ?>"/></td>
		</tr>
		<?php
		}
		?>
		<!--<tr>
		  <td class="title">资讯小标题</td>
		  <td><input type="text" name="textfield" class="wp80" /></td>
		</tr>-->
		<?php if($displaycity): ?>
		<tr>
		  <td class="title">*所属地区</td>
	      <td>
		  <table border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td>
			  	<select name="s1" id="s1" onChange="redirect(this.options.selectedIndex)">
					<option selected value="0">请选择</option>
					<?php
				  		$right = array();
				  		$k=1;
				  		if (isset($article['classes'])) {
							$selectedClasses = (array)$article['city_id'];
						} else {
							$selectedClasses = array();
						}
				  		foreach ($classes as $class):
					        $c = count($right);
							if ($c > 0) {
								while ($c > 0 &&
					                $right[$c - 1] < $class['right_value'])
					            {
									array_pop($right);
									$c = count($right);
								}	
							}
				
						$right[] = $class['right_value'];
						if($c == 0):
				  	?>
					<option value="<?php echo $class['class_id']; ?>" <?php if (in_array($class['class_id'], $selectedClasses)): ?>selected<?php endif; ?> id="<?php echo $k; ?>"><?php echo $class['name']; ?></option>
					<?php $k++;endif;endforeach; ?>
			  </td>
              <td>&nbsp;</td>
              <td><select name="s2" id="s2"><option value="请选择" selected>请选择</option></select></td>
              <td>&nbsp;</td>
            </tr>
          </table>		  </td>
	  </tr>
	  <?php endif; ?>
		<tr>
		  <td valign="top" class="title">*正文内容</td>
		  <td>
		  <?php 
			include(SHARED_DIR."/editor/spaw2/spaw.inc.php"); 
			$spaw = new SpawEditor("spaw1", $article['content']); 
			$spaw->show();
		?>
		  </td>
		</tr>
		<?php
		if($displayhot){
		?>
		<tr>
		  <td valign="top" class="title">是否急聘</td>
		  <td>
		  <select name="hot" id="hot">
			<option value="0" <?php if($article['hot'] == 0) echo 'selected';?>>否</option>
			<option value="1" <?php if($article['hot'] == 1) echo 'selected';?>>是</option>
		  </select>
		  </td>
		</tr>
		<?php
		}
		?>
		<tr>
		  <td align="right" colspan="2">
              <button type="submit" name="Save" id="Save" class="btnA">发布</button>&nbsp;&nbsp;
              <input name="Cancel" type="button" id="Cancel" value="<?php echo h(_T('ui_g_cancel')); ?>" onclick="fnOnBack();" />
          </td>
	    </tr>
		<tr>
		  <td>&nbsp;</td>
		  <td></td>
		</tr>
	</table>
	<input name="<?php echo $pk; ?>" type="hidden" id="<?php echo $pk; ?>" value="<?php echo $article[$pk]; ?>"/>
	<input name="class_id" type="hidden" id="class_id" value="<?php echo $article['class_id']; ?>"/>
  </form>
</div>
<div id="main_copy">Copyright&copy;2003 – 2009 ITeam Monkey. All Rights Reserved ITeam Monkey 版权所有 </div>
<script language="javascript" type="text/javascript">
  	//获取一级菜单长度
	var select1_len = document.form1.s1.options.length;
	var select2 = new Array(select1_len);
	//把一级菜单都设为数组
	for (i=0; i<select1_len; i++)
	{ select2[i] = new Array();}
  	//定义基本选项
	select2[0][0] = new Option("请选择", "0");
  	<?php
  		$right = array();
  		$d = 1;$v = 0;$k = 0;
  		foreach ($classes as $class):
	        $c = count($right);
			if ($c > 0) {
				while ($c > 0 &&
	                $right[$c - 1] < $class['right_value'])
	            {
					array_pop($right);
					$c = count($right);
				}	
				if($c == 0){
					$d++;
					$v = 0;
				}
			}

		$right[] = $class['right_value'];
		if($c != 0):
  	?>
	select2[<?php echo $d; ?>][<?php echo $v-1; ?>] = new Option("<?php echo $class['name']; ?>", "<?php echo $class['class_id']; ?>");

	<?php $k++;endif;$v++;endforeach; ?>
	//联动函数
	function redirect(x,y)
	{
		var temp = document.form1.s2;
		for (m=temp.options.length-1;m>0;m--)
		temp.options[m]=null  //清空选项
		for (i=0;i<select2[x].length;i++)
		{ 
			temp.options[i]=new Option(select2[x][i].text,select2[x][i].value);
		}
		temp.options[0].selected=true;
		if(y>0)temp.options[y].selected=true;
	}
	
	function setredirect(cityid){
		if(!cityid)return false;
		var temp1 = document.form1.s1;
		var temp2 = document.form1.s2;
		for (i=1;i<select1_len;i++)
		{ 
			for (j=0;j<select2[i].length;j++){ 
				if(cityid == select2[i][j].value){
					temp1.options[i].selected=true;
					redirect(i,j);
					break;
				}
			}
		}
		
	}
	
//	redirec();//default
  </script>
</body>
</html>
